package com.novak.rss.reader;

import android.app.Activity;
import android.app.Service;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.Menu;
import android.view.MenuItem;

public class VibratorViewActivity extends Activity
{
  private Vibrator vibrator;

  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    setContentView(R.layout.vibrator);
    vibrator = (Vibrator) getApplication().getSystemService(
        Service.VIBRATOR_SERVICE);
    toVibrate();
  }

  private void toVibrate()
  {
     vibrator.vibrate(new long[]{100,100,100,1000}, 0);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu)
  {
    vibrator.cancel();
    menu.addSubMenu(0, 2, 0, "继续");
    menu.addSubMenu(0, 3, 0, "返回");
    return true;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item)
  {
    switch (item.getItemId()){
      case 2:
        toVibrate();
        return true;
      case 3:
        finish();
        return true;
    }
    return false;
  }
  

}
